#pragma once
#include "SingletonBase.h"

namespace pktoon
{
	class IInputHookListener
	{
	public:
		virtual bool OnKey(WPARAM wparam, const KBDLLHOOKSTRUCT& event) = 0;
		virtual bool OnMouse(WPARAM wparam, const MSLLHOOKSTRUCT& event) = 0;
	};

	class InputHook : public pktoon::SingletonBase<InputHook>
	{
	public:
		InputHook(IInputHookListener* listener) : mListener(listener) {mMouseHook = 0; mKeyHook = 0; mStartKey = true; mStartMouse = true; };
		virtual ~InputHook(void) {mListener = 0;}
		
		const HHOOK GetKeyHook() const { return mKeyHook; }
		const HHOOK GetMouseHook() const { return mMouseHook; }

		void SetStartKey(bool val) { mStartKey = val; }
		void SetStartMouse(bool val) { mStartMouse = val; }

		bool Start();
		bool Stop();

		static void Initialize(IInputHookListener* listener)
		{
			sInstance = new InputHook(listener);
		}

		LRESULT OnKeybdProc(int aCode, WPARAM wParam, LPARAM lParam);
		LRESULT OnMouseProc(int aCode, WPARAM wParam, LPARAM lParam);
	protected:
		InputHook();
		static void Initialize();
	private:

		
		HHOOK mMouseHook;
		
		bool mStartMouse;
		bool mStartKey;
		HHOOK mKeyHook;
		
		static LRESULT CALLBACK LowLevelKeybdProc(int aCode, WPARAM wParam, LPARAM lParam);
		static LRESULT CALLBACK LowLevelMouseProc(int aCode, WPARAM wParam, LPARAM lParam);

		IInputHookListener* mListener;
	};
}	